This is a work in progress - all content and analyses are preliminary.
Economics
1 Dimension Overview
Shown in the diagram below are a total of 45 indicators within the economics dimension. Indices are labeled within the diagram. 17 indicators are both included in the Wiltshire et al. framework as well as being studied by one or more teams (red), 9 are included in the Wiltshire et al. but not currently belong studied (green), while 19 were not in the original framework, but have been added by one or more teams (blue).
The points beside each indicator name represent the number of secondary data metrics that have been aggregated for each indicator. Sources include USDA NASS, BLS, ERS, Census Bureau, and others. The quality and appropiateness of these metrics vary widely - I do not mean to suggest that having more of them means an indicator is more accurately better represented. For more information on the data sources, head to Section 2 below.
One other point to note here is that I removed several dozen metrics from BLS wage labor data broken down by NAICS industry code so as not to inflate that indicator relative to the others.
Code
## Load packagespacman::p_load( ggraph, igraph, dplyr, RColorBrewer, viridisLite, ggrepel, stringr)conflicted::conflicts_prefer( dplyr::as_data_frame(),.quiet =TRUE)## Load data for tree and metricsdat <-readRDS('data/trees/econ_tree.rds') %>%select(Dimension:Source)metadata_all <-readRDS('data/sm_data.rds')[['metadata']]meta <- metadata_all %>%filter( dimension =='economics' )# Rename metadata so it fits into formatting of tree data# This is quite not ideal - Note to harmonize this properly latermeta <- meta %>%mutate(indicator =str_to_sentence(indicator),indicator =case_when(str_detect(indicator, '^Assets') ~'Balance sheet (assets and liabilities)',str_detect(indicator, '^Business failure') ~'Business failure rate of food business',str_detect(indicator, '^Direct') ~'% direct-to-consumer sales',str_detect(indicator, '^Job avail') ~'Availability of good-paying jobs in food systems',str_detect(indicator, '^Local sales') ~'% local sales',str_detect(indicator, '^Operator salary') ~'Operator salary / wage',str_detect(indicator, '^Total sales') ~'Total sales / revenue',str_detect(indicator, '^Wealth/income') ~'Wealth / income distribution',TRUE~ indicator ) ) # Join counts of secondary data metrics to original dataset# Remove the NAICS variables - there are so many of them, don't add muchcounts <- meta %>%filter(str_detect(variable_name, '^lq|lvl|Lvl|Naics', negate =TRUE)) %>%group_by(indicator) %>% dplyr::summarize(count =n())## Make edges# include groupings by dimension, then combine themedges <-list()edges$dim_ind <- dat %>%select(Dimension, Index) %>%unique() %>% dplyr::rename(from = Dimension, to = Index) %>%mutate(group = to)edges$ind_ind <- dat %>%select(Index, Indicator) %>%unique() %>% dplyr::rename(from = Index, to = Indicator) %>%mutate(group = from)edges <-bind_rows(edges)# Add column for use (will use in colors of text?)edges$group <-c(rep(NA, 10), dat$Source)## Make vertices# Each line is a single vertex (dimension, index, or indicator)# We are just giving them random values to control point size for nowvertices =data.frame(name =unique(c(as.character(edges$from), as.character(edges$to)))) %>%left_join(counts, by =join_by(name == indicator)) %>% dplyr::rename('value'= count)# Add the dimension groupings to the vertices as wellvertices$group = edges$group[match(vertices$name, edges$to)]# Calculate the angles to arrange indicator labelsvertices$id =NAmyleaves =which(is.na(match(vertices$name, edges$from)))nleaves =length(myleaves)vertices$id[myleaves] =seq(1:nleaves)vertices$angle =90-360* vertices$id / nleaves# Calculate alignment of indicator labelsvertices$hjust <-ifelse(vertices$angle <-90, 1, 0)# Flip label angles around 180 degrees if they are facing the wrong wayvertices$angle <-ifelse(vertices$angle <-90, vertices$angle +180, vertices$angle)## Create graph# Make ggraph object from edges and verticesgraph <-graph_from_data_frame(edges, vertices = vertices)# Plot the graphggraph(graph, layout ='dendrogram', circular =TRUE) +# Color edges by dimensiongeom_edge_diagonal(color ='black', width =0.5) +# Create text for indicators using angles, hjust, and dimension groupingsgeom_node_text(aes(x = x *1.15,y = y *1.15,filter = leaf,label = name,angle = angle,hjust = hjust,colour = group ),size =3,alpha =1 ) +# Label indices within graphgeom_label_repel(aes(x = x,y = y,label =ifelse(name %in%unique(dat$Index), name, NA) ),label.padding =unit(0.15, "lines"),label.r =unit(0.3, "lines"),label.size =0.05,size =2.25,force =0.1, force_pull =1, max.overlaps =10 ) +# Make the points for indicators based on secondary metric countgeom_node_point(aes(filter = leaf,x = x *1.07,y = y *1.07,colour = group,size = value ),alpha =0.4 ) +# Various formatting optionsscale_colour_manual(values =brewer.pal(3, 'Set1')) +# scale_size_continuous(range = c(0.1, 7)) +theme_void() +theme(plot.margin =unit(c(0, 0, 0, 0), "cm") ) +scale_colour_manual(name ="Indicator Use",values =brewer.pal(3, 'Set1'),labels =c("Both", "Current Only", "Wiltshire Only") ) +expand_limits(x =c(-2.5, 2.5), y =c(-2.5, 2.5))
Radial dendrogram of Sustainability Metrics framework
2 Metadata Table
This is table to explore metadata for secondary metrics data. It does not include the values or geographic areas themselves, but does include definitions, sources, and links to the data used.
Using the table:
Click column headers to sort
Global search in the top right, or column search in each header
Change page length and page through results at the bottom
Use the download button to download a .csv file of the filtered table
Click the arrow on the left of each row for details, including a URL to the data source.
This is another table that includes values. It takes some more legwork to navigate through years and counties, but all the secondary data is included here. Again, use the button to download the filtered view of the table.
Code
pacman::p_load( dplyr, reactable, stringr, htmltools)# Load metrics and metadatametadata_all <-readRDS('data/sm_data.rds')[['metadata']]metrics <-readRDS('data/sm_data.rds')[['metrics']]fips_key <-readRDS('data/sm_data.rds')[['fips_key']]# Value formatting function based on unitssource('dev/format_values.R')# Filter to economics metrics, join with metadata and county fips codesecon_metrics <- metrics %>%left_join(metadata_all, by =join_by('variable_name')) %>%filter(dimension =='economics') %>%left_join(fips_key, by =join_by('fips')) %>%mutate(county_name =ifelse(is.na(county_name), state_name, county_name)) %>%format_values() %>%select( metric,'Variable Name'= variable_name, definition,year = year.x,Area = county_name, units, value ) %>%setNames(c(str_to_title(names(.)))) %>%filter(!is.na(Value))## Reactable tablehtmltools::browsable(tagList( tags$div(style ="display: flex; gap: 16px; margin-bottom: 20px; justify-content: center;", tags$button(class ="btn btn-primary",style ="display: flex; align-items: center; gap: 8px; padding: 8px 12px;",tagList(fontawesome::fa("download"), "Download as CSV"),onclick ="Reactable.downloadDataCSV('metrics_table', 'sustainability_metrics.csv')" ) ),reactable( econ_metrics,sortable =TRUE,resizable =TRUE,filterable =TRUE,searchable =TRUE,pagination =TRUE,bordered =TRUE,wrap =TRUE,rownames =FALSE,onClick ='select',striped =TRUE,pageSizeOptions =c(5, 10, 25, 50, 100),defaultPageSize =5,showPageSizeOptions =TRUE,highlight =TRUE,style =list(fontSize ="14px"),compact =TRUE,columns =list(Metric =colDef(minWidth =125,sticky ='left' ),'Variable Name'=colDef(minWidth =125 ),Definition =colDef(minWidth =250 ),Units =colDef(minWidth =100),'Year'=colDef(minWidth =100) ),defaultColDef =colDef(minWidth =100),elementId ="metrics_table" ) ))